package dm.ast.model.gen;

import dm.ast.DmASTNode;
import dm.ast.model.gen.factory.BaseModelFactory;
import dm.repository.DmIFunInfo;
import test.envset.GlobalState;

/**
 * 根据模板AST生成基础类
 */
public abstract class ASTGenBase {
    //static GlobalState globalState = null;
    //*Gen通过此变量读取BaseModelFactory中的testFlags
    protected boolean[] testFlags;

    public static void init(GlobalState globalState){
        BaseModelFactory.setGlobalState(globalState);
//        testIfuns(globalState);
    }

    public static void testIfuns(GlobalState globalState){
        if(globalState == null){
            System.err.println("ASTGenBase not init");
            System.exit(1);
        }
        DmIFunInfo.testIfuns(globalState);
//        System.exit(0);
    }

    //根据宽度、深度生成满足要求的节点
    public abstract DmASTNode gen(int astLevel , int wid_t , int dep_t);

    /**
     * 每次调用gen前调用此方法设置testFlags
     * @param testFlags
     */
    public void setTestFlags(boolean[] testFlags){
        this.testFlags = testFlags;
    }

}
